/**
 * Copyright (C) 2012 The SkyTvOS Project
 * <p/>
 * Version     Date           Author
 * ─────────────────────────────────────
 * 2014-10-31         Root.Lu
 */

package com.coocaa.x.service.litedownloader.data;

import android.os.Parcelable;

import com.coocaa.x.framework.data.JObject;

import java.util.UUID;

public class DownloadTask extends JObject {
    public static final int TASK_CODE_OK = 0;
    public static final int TASK_CODE_ALREADY_EXIST = TASK_CODE_OK - 1;
    public static final int TASK_CODE_NOT_EXIST = TASK_CODE_OK - 2;
    public static final int TASK_CODE_ALREADY_START = TASK_CODE_OK - 3;
    public static final int TASK_CODE_ALREADY_FINISH = TASK_CODE_OK - 4;
    public static final int TASK_CODE_NOT_START = TASK_CODE_OK - 5;
    public static final int TASK_CODE_ALREADY_DOING_STOP = TASK_CODE_OK - 6;
    public static final int TASK_CODE_ALREADY_DOING_DELETE = TASK_CODE_OK - 7;


    public static final String WITH_OUT_MD5 = "WITH_OUT_MD5";

    public String ID = null;
    public String title = "";
    public String url = "";
    public String filename = "";
    public String savepath = "";
    public String extra = "";
    public long createtime = System.currentTimeMillis();
    public TaskInfo info = new TaskInfo();
    public String md5 = WITH_OUT_MD5;

    public DownloadTask() {
        ID = UUID.randomUUID().toString();
    }

    public DownloadTask(String ID) {
        this.ID = ID;
    }

    @Override
    public boolean equals(Object o) {
        // TODO Auto-generated method stub
        try {
            return ID.equals(((DownloadTask) o).ID);
        } catch (Exception e) {
            return false;
        }
    }

    public static final Parcelable.Creator<DownloadTask> CREATOR = createCREATOR(
            DownloadTask.class, null);
}
